<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    :confirmLoading="confirmLoading"
    switchFullscreen
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭"
  >
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">
        <a-form-item label="所属部门" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['sysOrgCode']" placeholder="请输入所属部门"></a-input>
        </a-form-item>
        <a-form-item label="微信ID" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['query03']" placeholder="请输入微信ID"></a-input>
        </a-form-item>
        <a-form-item label="电话" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['query04']" placeholder="请输入电话"></a-input>
        </a-form-item>
        <a-form-item label="姓名" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['query05']" placeholder="请输入姓名"></a-input>
        </a-form-item>
        <a-form-item label="头像" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <j-image-upload isMultiple v-decorator="['query06']"></j-image-upload>
        </a-form-item>
        <a-form-item label="机构名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['query07']" placeholder="请输入机构名称"></a-input>
        </a-form-item>
        <a-form-item label="机构分类" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['query08']" placeholder="请输入机构分类"></a-input>
        </a-form-item>
        <a-form-item label="机构详情" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <j-editor v-decorator="['query09', { trigger: 'input' }]" />
        </a-form-item>
        <a-form-item label="机构图片" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <j-image-upload isMultiple v-decorator="['query10']"></j-image-upload>
        </a-form-item>
        <a-form-item label="机构地址" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['query11']" placeholder="请输入机构地址"></a-input>
        </a-form-item>
        <a-form-item label="机构电话" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['query12']" placeholder="请输入机构电话"></a-input>
        </a-form-item>
        <a-form-item label="机构联系人" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['query13']" placeholder="请输入机构联系人"></a-input>
        </a-form-item>
        <a-form-item label="经度" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['query14']" placeholder="请输入经度"></a-input>
        </a-form-item>
        <a-form-item label="维度" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['query15']" placeholder="请输入维度"></a-input>
        </a-form-item>
        <a-form-item label="是否分店" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['query16']" placeholder="请输入是否分店"></a-input>
        </a-form-item>
        <a-form-item label="上级机构" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['query17']" placeholder="请输入上级机构"></a-input>
        </a-form-item>
        <a-form-item label="banner" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['query18']" placeholder="请输入banner"></a-input>
        </a-form-item>
        <a-form-item label="推荐" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['query19']" placeholder="请输入推荐"></a-input>
        </a-form-item>
        <a-form-item label="发现" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['query20']" placeholder="请输入发现"></a-input>
        </a-form-item>
        <a-form-item label="赛事" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['query21']" placeholder="请输入赛事"></a-input>
        </a-form-item>
        <a-form-item label="猜你喜欢" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['query22']" placeholder="请输入猜你喜欢"></a-input>
        </a-form-item>
        <a-form-item label="在看" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['query23']" placeholder="请输入在看"></a-input>
        </a-form-item>
        <a-form-item label="已读" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['query24']" placeholder="请输入已读"></a-input>
        </a-form-item>
        <a-form-item label="转发" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['query25']" placeholder="请输入转发"></a-input>
        </a-form-item>
        <a-form-item label="小标签" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['query26']" placeholder="请输入小标签多个以,隔开 最多3个"></a-input>
        </a-form-item>
        <a-form-item label="推荐星级" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['query27']" placeholder="请输入推荐星级1~5星"></a-input>
        </a-form-item>
        <a-form-item label="营业时间" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['query28']" placeholder="请输入营业时间"></a-input>
        </a-form-item>
        <a-form-item label="配套服务" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['query29']" placeholder="请输入配套服务（,隔开）"></a-input>
        </a-form-item>
        <a-form-item label="地区query30" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['query30']" placeholder="请输入转发"></a-input>
        </a-form-item>
        <a-form-item label="品牌介绍" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['query31']" placeholder="请输入品牌介绍"></a-input>
        </a-form-item>
        <a-form-item label="图片介绍" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <j-image-upload isMultiple v-decorator="['query32']"></j-image-upload>
        </a-form-item>
        <a-form-item label="本条数据类型" :labelCol="labelCol" :wrapperCol="wrapperCol">
           <a-input v-decorator="['query33']" placeholder="请输入数据类型"></a-input>
        </a-form-item>
      </a-form>
    </a-spin>
  </j-modal>
</template>

<script>
import { httpAction } from '@/api/manage'
import pick from 'lodash.pick'
import { validateDuplicateValue } from '@/utils/util'
import JImageUpload from '@/components/jeecg/JImageUpload'
import JEditor from '@/components/jeecg/JEditor'

export default {
  name: 'EduBuse_08Modal',
  components: {
    JImageUpload,
    JEditor
  },
  data() {
    return {
      form: this.$form.createForm(this),
      title: '操作',
      width: 800,
      visible: false,
      model: {},
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      },
      confirmLoading: false,
      validatorRules: {},
      url: {
        add: '/buse/eduBuse_08/add',
        edit: '/buse/eduBuse_08/edit'
      }
    }
  },
  created() {},
  methods: {
    add() {
      this.edit({})
    },
    edit(record) {
      this.form.resetFields()
      this.model = Object.assign({}, record)
      this.visible = true
      this.$nextTick(() => {
        this.form.setFieldsValue(
          pick(
            this.model,
            'sysOrgCode',
            'query03',
            'query04',
            'query05',
            'query06',
            'query07',
            'query08',
            'query09',
            'query10',
            'query11',
            'query12',
            'query13',
            'query14',
            'query15',
            'query16',
            'query17',
            'query18',
            'query19',
            'query20',
            'query21',
            'query22',
            'query23',
            'query24',
            'query25',
            'query26',
            'query27',
            'query28',
            'query29',
            'query30',
            'query31',
            'query32',
            'query33'
          )
        )
      })
    },
    close() {
      this.$emit('close')
      this.visible = false
    },
    handleOk() {
      const that = this
      // 触发表单验证
      this.form.validateFields((err, values) => {
        if (!err) {
          that.confirmLoading = true
          let httpurl = ''
          let method = ''
          if (!this.model.id) {
            httpurl += this.url.add
            method = 'post'
          } else {
            httpurl += this.url.edit
            method = 'put'
          }
          let formData = Object.assign(this.model, values)
          console.log('表单提交数据', formData)
          httpAction(httpurl, formData, method)
            .then(res => {
              if (res.success) {
                that.$message.success(res.message)
                that.$emit('ok')
              } else {
                that.$message.warning(res.message)
              }
            })
            .finally(() => {
              that.confirmLoading = false
              that.close()
            })
        }
      })
    },
    handleCancel() {
      this.close()
    },
    popupCallback(row) {
      this.form.setFieldsValue(
        pick(
          row,
          'sysOrgCode',
          'query03',
          'query04',
          'query05',
          'query06',
          'query07',
          'query08',
          'query09',
          'query10',
          'query11',
          'query12',
          'query13',
          'query14',
          'query15',
          'query16',
          'query17',
          'query18',
          'query19',
          'query20',
          'query21',
          'query22',
          'query23',
          'query24',
          'query25',
          'query26',
          'query27',
          'query28',
          'query29',
          'query30',
          'query31',
          'query32',
          'query33'
        )
      )
    }
  }
}
</script>
